package blservice.document;
import java.rmi.Remote;
import java.rmi.RemoteException;



import java.util.List;

import vo.DocumentVo;
import vo.Vo;

public interface DocumentBLService  extends Remote{
	public Vo approve(DocumentVo document) throws RemoteException;
	public Vo add(DocumentVo document) throws RemoteException;
	public Vo update(DocumentVo document) throws RemoteException;
	public List<DocumentVo> get(DocumentVo from,DocumentVo to) throws RemoteException;
	public List<DocumentVo> getUnapproval() throws RemoteException;
	public Vo redRush(DocumentVo document) throws RemoteException;
	
	default public Vo redRushAndCopy(DocumentVo document) throws RemoteException{
		Vo m=new Vo();
		DocumentVo from=new DocumentVo();
		from.setType(document.isType());
		DocumentVo to=new DocumentVo();
		List<DocumentVo> list=get(from,to);
		for(int i=0;i<list.size();i++){
			if(list.get(i).get单据编号().equals(document.get单据编号())){
				list.get(i).setOperator(document.getOperator());
				list.get(i).set业务员(document.get业务员());
				Vo r1=redRush(list.get(i));
			    if(!r1.isSuccessed()){
			    	m.failed("红冲失败!");
			    	return m;
			    }
			}
		}
		Vo r=add(document);
		if(r.isSuccessed()){
			m.successed();
		}else{
			m.failed("添加失败！");
		}
	    return m;
	}
    
    
}
